<template>
	<view>
		<nav-bar fontColor="#FFFFFF" title="开通产品"></nav-bar>
		<view class="centerBoxtitle">开通流程</view>
		<uni-card class="margin" :is-shadow="true">
			<view style="margin: 20rpx;font-size: 35rpx;font-weight: bold;">申请额度</view>
			<uni-steps :options="list1" :active="active1" />
			<button style="float: right;margin: 20rpx;" size="mini" type="primary" :disabled="applyStatus"
				@click="apply">去申请</button>
			<button style="float: right;margin: 20rpx;" size="mini" type="primary" v-if="applyStatus"
				@click="jump">去跳转</button>
		</uni-card>
		<uni-card class="margin" :is-shadow="true">
			<view style="margin: 20rpx;font-size: 35rpx;font-weight: bold;">激活额度</view>
			<uni-steps :options="list2" :active="active2" />
			<button style="float: right;margin: 20rpx;" size="mini" type="primary" :disabled="activateStatus" @click="submit">去激活</button>
		</uni-card>
		<view class="centerBoxtitle" @click="jumpOutside">必备资料</view>
		<view class="width">
			<view class="bottomBox">
				<view class="bottomTitle">营业执照</view>
				<view class="bottomContent">
					图片内容清晰，在有效期内至少60天。
				</view>
			</view>
			<view class="bottomBox">
				<view class="bottomTitle">法定代表人身份证</view>
				<view class="bottomContent">
					图片内容清晰，在有效期内至少60天。
				</view>
			</view>
		</view>
		<view class="width">
			<view class="bottomBox">
				<view class="bottomTitle">对公银行账户</view>
				<view class="bottomContent">
					中国人民银行开通的基本户或...
				</view>
			</view>
			<view class="bottomBox">
				<view class="bottomTitle">联系方式</view>
				<view class="bottomContent">
					企业联系电话、邮箱、法人联系电话、联系人电话
				</view>
			</view>
		</view>
		<!-- <view class="width">
			<view class="bottomBox">
				<view class="bottomTitle">对公银行账户</view>
				<view class="bottomContent">
					中国人民银行开通的基本户或...
				</view>
			</view>
			<view style="width: 47%;">
			</view>
		</view> -->
		<!-- <uni-collapse accordion  v-model="accordionVal">
			<uni-collapse-item title="手风琴效果" >
				1
			</uni-collapse-item>
		</uni-collapse> -->
		<uni-popup ref="inputDialog" type="dialog">
			<uni-popup-dialog title="选择贸易背景" ref="inputClose" mode="chooseCompany" @confirm="confirm">
			</uni-popup-dialog>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				active1: 0,
				accordionVal: '1',
				list1: [{
					title: '补充资料'
				},{
					title: '签署合同'
				},{
					title: '业务审批'
				}, {
					title: '获得额度'
				}],
				active2: 0,
				list2: [{
					title: '签署合同'
				}, {
					title: '绑定对公户'
				}, {
					title: '业务审批'
				}, {
					title: '激活额度'
				}],
				form: {},
				form1: {},
				creditForm: {},
				applyStatus: true,
				activateStatus: true
			}
		},
		onLoad(e) {
			if(e){
				this.form1 = e.id
				this.form = JSON.parse(e.id)
				this.searchStatus();
				console.log(this.form)
				
			}
			// uni.navigateTo({
			// 	url: 'weixin://dl/businessWebview/' + '02nJCR4QjscEk10000007D'
			// })
			// window.location.href = 'weixin://dl/businessWebview/' + '02nJCR4QjscEk10000007D'
		},
		methods: {
			jumpOutside() {
				window.location.href =
					'https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=Mzg5Mzg2MTkzNg==&scene=110#wechat_redirect'
			},
			jump(){
				if(this.form.productName == '酒易贷'){
					uni.navigateTo({
						url:'/pages/login/jdLogin'
					})
				}
				else{
					uni.navigateTo({
						url:'/pages/limit/qrCode'
					})
				}
			},
			searchStatus() {
				let opt = {
					url: 'baoli/finCustomerCreditApplication/search',
					method: 'POST'
				};
				let params = {
					customerNo: uni.getStorageSync('userInfo').customerId,
					productNo: this.form.id
				}
				this.$http.httpTokenRequest(opt, params).then(res => {
					if (res.data.code == 200 && res.data.data != '') {
						if (res.data.data[0].proveStatus == 'applied') {
							this.active1 = 2;
							this.active2 = 0;
							this.applyStatus = true;
							this.activateStatus = true;
							uni.showToast({
								title: '申请中',
								icon: 'none',
								duration: 1500
							});
						} else if (res.data.data[0].proveStatus == 'rejected') {
							this.active1 = 0;
							this.active2 = 0;
							this.applyStatus = false;
							this.activateStatus = true;
							uni.showToast({
								title: '已拒绝，请重新开通',
								icon: 'none',
								duration: 1500
							});
						}else if (res.data.data[0].proveStatus == 'actived') {
							this.active1 = 3;
							this.active2 = 0;
							this.applyStatus = true;
							this.activateStatus = true;
							uni.showToast({
								title: '已激活',
								icon: 'none',
								duration: 1500
							});
						}
						 else if (res.data.data[0].proveStatus == 'submitted') {
							this.active1 = 2;
							this.active2 = 0;
							this.applyStatus = true;
							this.activateStatus = false;
							uni.showToast({
								title: '已提交',
								icon: 'none',
								duration: 1500
							});
						} else if (res.data.data[0].proveStatus == 'proved') {
							this.active1 = 3;
							this.active2 = 3;
							this.applyStatus = true;
							this.activateStatus = true;
							uni.showToast({
								title: '产品开通成功',
								icon: 'none',
								duration: 1500
							});
						} else {
							this.active1 = 3;
							this.active2 = 3;
							this.applyStatus = true;
							this.activateStatus = true;
							uni.showToast({
								title: '开通成功，请勿重复开通',
								icon: 'none',
								duration: 1500
							});
						}
					} else {
						this.active1 = 0;
						this.active2 = 0;
						this.applyStatus = false;
						this.activateStatus = true;
					}
				})
			},
			apply() {
				// uni.showToast({
				// 	title:'申请成功!请等待审核',
				// 	icon:'success',
				// 	duration: 2000
				// })
				this.$refs.inputDialog.open();
				// uni.navigateTo({
				// 	url:'/pages/product/apply?id='+this.form
				// })
			},
			submit() {
				let opt = {
					url: 'finance/customerCredit',
					method: 'POST'
				};
				let params = {
					finProductNo: this.form.id,
					customerId: uni.getStorageSync('userInfo').customerId
				}
				this.$http.httpTokenRequest(opt, params).then(res => {
					if (res.data.code == 200) {
						uni.showToast({
							title: res.data.msg,
							icon: 'success',
							duration: 1500
						});
						// setTimeout(()=>{
						// 	uni.navigateBack({
						// 		delta: 2
						// 	})
						// },1500)
					} else {
						uni.showToast({
							title: res.data.msg,
							icon: 'error',
							duration: 1500
						});
					}
				})
			},
			confirm() {
				uni.navigateTo({
					url: '/pages/product/apply?params=' + this.form1
				})
				// uni.showToast({
				// 	title:'申请成功!请等待审核',
				// 	icon:'success',
				// 	duration: 2000
				// })
			}
		}
	}
</script>

<style>
	page {
		background: #f4f4f4;
	}

	.centerBoxtitle {
		font-size: 35rpx;
		color: #000000;
		font-weight: bold;
		margin: 28rpx;

	}

	.margin {
		margin: 40rpx 0;
	}

	.width {
		width: 95%;

		margin: 0 auto;
		margin-top: 30rpx;
		display: flex;
		justify-content: space-around;
	}

	.bottomBox {
		width: 47%;
		height: 150rpx;
		padding: 10rpx;
		border: 1px solid #e7e7e7;
		background: #FFFFFF;
		border-radius: 15rpx;
	}

	.bottomTitle {
		font-size: 28rpx;
		color: #000000;
		text-align: center;
		margin: 15rpx 0;
	}

	.bottomContent {
		font-size: 20rpx;
		color: #a5a5a5;
		text-align: center;
	}
</style>